package model.ability;

import model.core.Logger;
import model.effects.Effect;
import model.entity.Entity;

/**
 * This class defines abilities that can be done anywhere on the map
 * to the caster of the ability via a hotkey.
 * @author Zachary
 */
public class SelfMapAbility extends MapAbility {
	/**
	 * Constructor for a SelfMapAbility.
	 */
	public SelfMapAbility(String name, PassiveSkill ps, int mana, int delay, 
			Effect baseEffect, AbilityType at) {
		super(name, ps, mana, delay, baseEffect, at);
	}
	
	/**
	 * Use the SelfMapAbility.  If successful, it will apply
	 * the effect, otherwise nothing will happen.
	 */
	public void useMapAbility(Entity caster){
		if(this.testProbability())
			this.applyEffectToCaster(caster);
		else
			Logger.getInstance().writeToLogger("Ability failed!");
		caster.diasbleAttack(this.getDelay());
	}
	
	/**
	 * Apply the effect to the caster of the ability.
	 */
	private void applyEffectToCaster(Entity caster){
		Effect effect = this.getDerivedEffect(caster);
		effect.doEffect(caster);
	}

}
